import { FormProps, FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table/src/types/table';
import { DescItem } from '/@/components/Description/index';
import { Pczt } from '/@/components/Pczt/index';
import { CheckList } from '/@/components/CheckList/index';
import { StatusIcon } from '/@/components/StatusIcon/index';
import { ImgIcon } from '/@/components/ImgIcon/index';
import { defineComponent, h } from 'vue';
import { Tag } from 'ant-design-vue';

export function getMergeBasicColumns(): BasicColumn[] {
  return [
    {
      title: '有无隐患',
      dataIndex: 'pczt',
      width: 200,
      customRender: ({ value }) => {
        return h(Pczt, {
          pcztVal: value,
        });
      },
    },
    {
      title: '房屋编号',
      width: 250,
      dataIndex: 'fwbh',
    },
    {
      title: '房主姓名',
      width: 250,
      dataIndex: 'hzxm',
    },
    {
      title: '地址',
      dataIndex: 'address',
    },

    {
      title: '自查时间',
      width: 200,
      dataIndex: 'createOn',
    },

  ];
}

export function getCommercialBasicColumns(): BasicColumn[] {
  return [
    {
      title: '排查状态',
      dataIndex: 'pczt',
      width: 200,
      customRender: ({ value }) => {
        return h(Pczt, {
          pcztVal: value,
        });
      },
    },
    {
      title: '场所名称(房屋地址)',
      width: 250,
      dataIndex: 'placeName',
    },
    {
      title: '公安标准地址',
      dataIndex: 'location',
    },
    {
      title: '是否属于107个重点村',
      width: 200,
      dataIndex: 'chongDianVillage',
    },
    {
      title: '级别',
      width: 150,
      dataIndex: 'level',
    },
    {
      title: '治安问题隐患',
      dataIndex: 'security',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '治安隐患问题整治措施',
      dataIndex: 'securityRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '违法建设隐患问题',
      dataIndex: 'illegalConstruction',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '违法建设隐患问题整治措施',
      dataIndex: 'illegalConstructionRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '侵街站道问题',
      dataIndex: 'invadeOccupyStreet',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '侵街站道问题整治措施',
      dataIndex: 'invadeOccupyStreetRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '安全生产隐患问题',
      dataIndex: 'safeProduction',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '安全生产隐患问题整治措施',
      dataIndex: 'safeProductionRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '无证无照经营问题',
      dataIndex: 'noLicense',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '无证无照经营问题整治措施',
      dataIndex: 'noLicenseRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '排查时间',
      width: 200,
      dataIndex: 'createOn',
    },
    {
      title: '修改时间',
      width: 200,
      dataIndex: 'modifiedOn',
    },
  ];
}

export function getResidentBasicColumns(): BasicColumn[] {
  return [
    {
      title: '排查状态',
      dataIndex: 'pczt',
      width: 200,
      customRender: ({ value }) => {
        return h(Pczt, {
          pcztVal: value,
        });
      },
    },
    {
      title: '场所名称(房屋地址)',
      dataIndex: 'placeName',
      width: 200,
    },
    {
      title: '公安标准地址',
      dataIndex: 'location',
    },
    {
      title: '户主姓名',
      width: 150,
      dataIndex: 'householder',
    },
    {
      title: '是否属于107个重点村',
      width: 200,
      dataIndex: 'chongDianVillage',
    },
    {
      title: '级别',
      width: 150,
      dataIndex: 'level',
    },
    {
      title: '实际居住人数',
      width: 150,
      dataIndex: 'realPopulation',
    },
    {
      title: '三层（含）及以上居住人数',
      width: 200,
      dataIndex: 'realPopulationAbove3Floors',
    },
    {
      title: '治安隐患问题',
      dataIndex: 'security',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '治安隐患问题整治措施',
      dataIndex: 'securityRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '违法建设隐患',
      dataIndex: 'illegalConstruction',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '违法建设隐患问题整治措施',
      dataIndex: 'illegalConstructionRemediation',
      width: 300,
      customRender: ({ value }) => {
        return h(CheckList, {
          checkVal: value,
        });
      },
    },
    {
      title: '排查时间',
      width: 200,
      dataIndex: 'createOn',
    },
    {
      title: '修改时间',
      width: 200,
      dataIndex: 'modifiedOn',
    },
  ];
}
// 城乡结合部重点村综合整治排查  --> 详情 ---> 详情
export function getResidentDetailColumns(): DescItem[] {
  return [
    {
      label: '排查状态',
      field: 'pczt',
      render: (curVal, data) => {
        return h(Pczt, {
          pcztVal: curVal,
        });
      },
    },
    {
      label: '场所名称(房屋地址)',
      field: 'placeName',
    },
    // 133
    {
      label: '公安标准地址',
      field: 'buildingAddress',
    },
    {
      label: '户主姓名',
      field: 'householder',
    },
    {
      label: '实际负责人姓名',
      field: 'actualPerson',
    },
    {
      label: '实际负责人电话',
      field: 'actualPersonPhone',
    },
    {
      label: '是否属于107个重点村',
      field: 'chongDianVillage',
    },
    {
      label: '级别',
      field: 'level',
      render: (curVal, data) => {
        if (0 == curVal) {
          return h(Tag, { color: 'green' }, () => '市级');
        }
        return h(Tag, { color: 'blue' }, () => '县级');
      },
    },
    {
      label: '整栋（院）居住总人数',
      field: 'realPopulation',
    },
    {
      label: '其中三层（含）及以上居住的人数',
      field: 'realPopulationAbove3Floors',
    },
    {
      label: '治安隐患问题',
      field: 'security',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '治安隐患问题整治措施',
      field: 'securityRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '违法建设隐患',
      field: 'illegalConstruction',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '违法建设隐患问题整治措施',
      field: 'illegalConstructionRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '排查时间',
      field: 'createOn',
    },
    {
      label: '修改时间',
      field: 'modifiedOn',
    },
  ];
}

export function getCommercialDetailColumns(): DescItem[] {
  return [
    {
      label: '排查状态',
      field: 'pczt',
      render: (curVal, data) => {
        return h(Pczt, {
          pcztVal: curVal,
        });
      },
    },
    {
      label: '场所名称(房屋地址)',
      field: 'placeName',
    },
    {
      label: '公安标准地址',
      field: 'buildingAddress',
    },
    {
      label: '场所(商户)名称',
      field: 'merchantName',
    },
    {
      label: '户主姓名',
      field: 'householder',
    },
    {
      label: '实际负责人姓名',
      field: 'actualPerson',
    },
    {
      label: '实际负责人联系电话',
      field: 'actualPersonPhone',
    },
    {
      label: '是否属于107个重点村',
      field: 'chongDianVillage',
    },
    {
      label: '级别',
      field: 'level',
      render: (curVal, data) => {
        if (0 == curVal) {
          return h(Tag, { color: 'green' }, () => '市级');
        }
        return h(Tag, { color: 'blue' }, () => '县级');
      },
    },
    {
      label: '治安问题隐患',
      field: 'security',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '治安隐患问题整治措施',
      field: 'securityRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '违法建设隐患问题',
      field: 'illegalConstruction',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '违法建设隐患问题整治措施',
      field: 'illegalConstructionRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '无证无照经营问题',
      field: 'noLicense',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '无证无照经营问题整治措施',
      field: 'noLicenseRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '侵街站道问题',
      field: 'invadeOccupyStreet',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '侵街站道问题整治措施',
      field: 'invadeOccupyStreetRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '安全生产隐患问题',
      field: 'safeProduction',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '安全生产隐患问题整治措施',
      field: 'safeProductionRemediation',
      render: (curVal, data) => {
        return h(CheckList, {
          checkVal: curVal,
        });
      },
    },
    {
      label: '排查时间',
      field: 'createOn',
    },
    {
      label: '修改时间',
      field: 'modifiedOn',
    },
  ];
}

export const searchFormSchema: FormSchema[] = [
  {
    field: 'pczt',
    label: '排查状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '无需排查', value: 3 },
        { label: '已排查', value: 2 },
        { label: '排查中', value: 1 },
        { label: '未排查', value: 0 },
      ],
      placeholder: '请选择排查状态',
    },
    labelWidth: '5em',
    colProps: { span: 8 },
  },
];

export function getBasicShortColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      width: 150,
      dataIndex: 'id',
      sorter: true,
      sortOrder: 'ascend',
    },
  ];
}

export function getMultipleHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 200,
    },
  ];
}

export function getCustomHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 200,
    },
  ];
}
const renderContent = ({ text, index }: { text: any; index: number }) => {
  const obj: any = {
    children: text,
    attrs: {},
  };
  if (index === 9) {
    obj.attrs.colSpan = 0;
  }
  return obj;
};
export function getMergeHeaderColumns(): BasicColumn[] {
  return [
    {
      title: 'ID',
      dataIndex: 'id',
      width: 300,
      customRender: renderContent,
    },
  ];
}
export const getAdvanceSchema = (itemNumber = 6): FormSchema[] => {
  const arr: any = [];
  for (let index = 0; index < itemNumber; index++) {
    arr.push({
      field: `field${index}`,
      label: `字段${index}`,
      component: 'Input',
      colProps: {
        xl: 12,
        xxl: 8,
      },
    });
  }
  return arr;
};
export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    schemas: [
      ...getAdvanceSchema(5),
      {
        field: `field11`,
        label: `Slot示例`,
        component: 'Select',
        slot: 'custom',
        colProps: {
          xl: 12,
          xxl: 8,
        },
      },
    ],
  };
}
export function getBasicData() {
  const data: any = (() => {
    const arr: any = [];
    for (let index = 0; index < 40; index++) {
      arr.push({
        id: `${index}`,
        name: 'John Brown',
        age: `1${index}`,
        no: `${index + 10}`,
        address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
        beginTime: new Date().toLocaleString(),
        endTime: new Date().toLocaleString(),
      });
    }
    return arr;
  })();
  return data;
}

export function getTreeTableData() {
  const data: any = (() => {
    const arr: any = [];
    for (let index = 0; index < 40; index++) {
      arr.push({
        id: `${index}`,
        name: 'John Brown',
        age: `1${index}`,
        no: `${index + 10}`,
        address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
        beginTime: new Date().toLocaleString(),
        endTime: new Date().toLocaleString(),
        children: [
          {
            id: `l2-${index}`,
            name: 'John Brown',
            age: `1${index}`,
            no: `${index + 10}`,
            address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
            beginTime: new Date().toLocaleString(),
            endTime: new Date().toLocaleString(),
          },
        ],
      });
    }
    return arr;
  })();

  return data;
}
